const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');

Page({
	data: {
    id : '',
		dataList: []
	},

	onLoad(options) {
    this.setData({
      id : options.id
    })
		this.getLeaveDinner(options.id);
  },
  
	getLeaveDinner(id) {
    var that = this;
    http.httpPost(config.dinnerLeaveDetail, {
			did : id
		}, function(e) {
      that.setData({
        dataList : e.data
      })
		});
  },
  
  agree(){
    var that = this;
    http.httpPost(config.updateDinnerLeave, {
      did : that.data.id,
      status : 1
		}, function(e) {
      wx.showToast({ title: e.msg, icon: 'none', duration: 1000, mask: true });setTimeout(function(){ wx.navigateBack({delta: 1})}, 1000);
		});
  },

  unagree(){
    var that = this;
    http.httpPost(config.updateDinnerLeave, {
      did : that.data.id,
      status : 2
		}, function(e) {
      wx.showToast({ title: e.msg, icon: 'none', duration: 1000, mask: true });setTimeout(function(){ wx.navigateBack({delta: 1})}, 1000);
		});
  },

	onReady() {
		if (!app.login()) {
			return;
		}
	}
})
